-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ddl : support ADMIN REPAIR TABLE to override bad tableInfo in meta & supply a REPAIR MODE for safely restart. #12046
Conversation
What would happen with partitioned tables? |
By now, partitioned tables are not supported to repair in this version. I will focus on it! |
67570dd
to
7844a73
Compare
Codecov Report
@@ Coverage Diff @@
## master #12046 +/- ##
===========================================
Coverage ? 80.1314%
===========================================
Files ? 475
Lines ? 117477
Branches ? 0
===========================================
Hits ? 94136
Misses ? 15888
Partials ? 7453 |
It's the internal docs and we'd better remove it. |
domain/domain.go
Outdated
// clean the tables and set repaired table. | ||
repairedDB.Tables = []*model.TableInfo{} | ||
repairedDB.Tables = append(repairedDB.Tables, tbl) | ||
RepairDBInfoMap[di.ID] = repairedDB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to check this map when executing create table
. The scenario is as follows:
There is a DDL operation that creates the table dbA_tblB before the operation of repairing dbA_tblB is started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense, I will check this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any test cases?
planner/core/preprocess.go
Outdated
@@ -724,6 +762,36 @@ func (p *preprocessor) handleTableName(tn *ast.TableName) { | |||
tn.DBInfo = dbInfo | |||
} | |||
|
|||
func (p *preprocessor) handleRepairName(tn *ast.TableName) { | |||
dbMap := domain.GetDomain(p.ctx).GetTablesInRepair() | |||
// tn only has the Schema here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tn
is a variable, addressed.
5d51ca1
to
65110bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to consider how to cancel this job?
/run-all-tests |
tidb-server/main.go
Outdated
repairString = repairString[1 : len(repairString)-1] | ||
} | ||
return strings.FieldsFunc(repairString, func(r rune) bool { | ||
if r == ',' || r == ' ' || r == '"' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about return if r == ',' || r == ' ' || r == '"'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
@@ -104,7 +104,7 @@ func IsJobRollbackable(job *model.Job) bool { | |||
model.ActionTruncateTable, model.ActionAddForeignKey, | |||
model.ActionDropForeignKey, model.ActionRenameTable, | |||
model.ActionModifyTableCharsetAndCollate, model.ActionTruncateTablePartition, | |||
model.ActionModifySchemaCharsetAndCollate: | |||
model.ActionModifySchemaCharsetAndCollate, model.ActionRepairTable: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test if we support canceling the job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
/run-all-tests |
return ErrRepairTableFail.GenWithStackByArgs("Column " + newOne.Name.L + " has lost") | ||
} | ||
if newOne.Tp != old.Tp { | ||
return ErrRepairTableFail.GenWithStackByArgs("Column " + newOne.Name.L + " type should be the same") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add the type of column to the error message?
Do we need to check the Flen
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't assume the too much element in the old (broken) version is reasonable,providing a certain degree of freedom for more robust repairs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
…supply a REPAIR MODE for safely restart. (pingcap#12046)
What problem does this PR solve?
This need the parser #547 merged first.
In some corner cases or encountering serious bugs, DDL operations update table structure error occurred, causing TiDB panic and failing to restart the service.
create new tableInfo from create table statement to override bad tableInfo in meta.
What is changed and how it works?
There are 2 steps to fix this:
1 : support special mode to start TiDB
2 : support a way to fix the bad tableInfo meta in KV store
Check List
Tests
Code changes
Related changes
Release note